package com.bouvet.wave;

import com.google.wave.api.*;


import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.logging.Logger;

public class WavePoCServlet extends AbstractRobotServlet {
	private static final Logger log = Logger.getLogger(WavePoCServlet.class
			.getName());

	Hashtable hashWavesChatBot;
	
	@Override
	public void processEvents(RobotMessageBundle bundle) {
		Wavelet wavelet = bundle.getWavelet();

		if (bundle.wasSelfAdded()) {
			Blip blip = wavelet.appendBlip();
			TextView textView = blip.getDocument();
			Gadget gadgetTagCloud = new Gadget("http://dapawave.appspot.com/tagcloud.xml");
			textView.appendElement(gadgetTagCloud);
			textView.append("I'm alive!");
		}

		for (Event e : bundle.getEvents()) {
			//log.info("Got event " + e);
			if (e.getType() == EventType.BLIP_SUBMITTED ){
				Blip orgBlip = e.getBlip();
				String strResponse= "dummy";
				if(strResponse!= null && !strResponse.trim().equals("")){
					Blip blip = orgBlip.createChild();
					TextView textView = blip.getDocument();
					textView.append(strResponse);
				}
				
			}
		}
	}

}